package com.deer.remote.server.rds.controller;

import com.deer.remote.common.protocol.Message;
import com.deer.remote.common.protocol.Packet;
import com.deer.remote.server.rds.BaseMessageController;
import com.deer.remote.server.rds.TentacleDesktopSession;

/**
 * Created by matrixy on 2019/1/4. 受控端对于远程控制请求的应答的处理
 */
public class RemoteControlResponseController extends BaseMessageController {
	@Override
	public boolean authenticateRequired() {
		return true;
	}

	@Override
	public Message service(TentacleDesktopSession session, Message msg) throws Exception {
		Packet resp = msg.getBody();
		int compressMethod = resp.nextByte() & 0xff;
		int bandWidth = resp.nextByte() & 0xff;
		int colorBits = resp.nextByte() & 0xff;
		int screenWidth = resp.nextShort() & 0xffff;
		int screenHeight = resp.nextShort() & 0xffff;
		session.getWebsocketContext().sendControlResponse(compressMethod, bandWidth, colorBits, screenWidth,
				screenHeight);

		return null;
	}
}
